﻿using Common.Communal;
using ERP.Domain.Scheduling;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Scheduling.Api.Read.Application.Command.ScheduleCommand;
using Scheduling.Api.Read.Application.Command.ShiftCommand;
using Scheduling.Api.Read.Application.Command.TeamCommand;
using Scheduling.Api.Read.Application.DTO;

namespace Scheduling.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TeamController : ControllerBase
    {
        public TeamController(IMediator mediator,ILogger<TeamController> logger) 
        {
            Mediator = mediator;
            Logger = logger;
        }

        public IMediator Mediator { get; }
        public ILogger<TeamController> Logger { get; }

        [HttpGet]
        public Task<ApiResult<ApiPaging<Team>>> GetTeam([FromQuery]TeamCreateCommand request)
        {
            Logger.LogInformation("班组显示成功");
            return Mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<TeamType>>> GetTeamType([FromQuery]TeamTypeCreateCommand request, CancellationToken cancellationToken)
        {
            return Mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<TeamMemberWithTeam>>> GetTeamMembers(int TeamId)
        {
            return Mediator.Send(new TeamMemberCreateCommand { TeamId = TeamId });
        }
        [HttpGet]
        public Task<ApiResult<List<Shift>>> GetShift([FromQuery]ShiftCreateCommand request, CancellationToken cancellationToken)
        {
            return Mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<ScheduleWithDetailsDTO>>> GetSchedules([FromQuery]ScheduleCreateCommand request, CancellationToken cancellationToken)
        {
            return Mediator.Send(request);
        }
    }
}
